﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations;

namespace RazorSourceGenerator
{
    class RequiredPathExistsAttribute : ValidationAttribute
    {
        public override bool IsValid(object value)
        {
            var path = value as string;
            if (string.IsNullOrEmpty(path))
                return true;

            if (System.IO.Directory.Exists(path))
                return true;
            else
                return false;
        }

        public override string FormatErrorMessage(string name)
        {
            return string.Format("{0} is not exists.", name);
        }
    }
}
